<include file="Common:header" />
<body>
	<form id="form1" name="form1" method="post" action="<{:U('save')}>">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="150" height="30" align="right">所属分类：</td>
				<td><select name="clsid" id="clsid">
						<option value="1">女装</option>
				</select></td>
			</tr>
			<tr>
				<td height="30" align="right">名称：</td>
				<td><input type="text" name="title" id="title" /></td>
			</tr>
			<tr>
				<td height="30" align="right">成本价：</td>
				<td><input type="text" name="cprice" id="cprice" /></td>
			</tr>
			<tr>
				<td height="30" align="right">会员价：</td>
				<td><input type="text" name="vprice" id="vprice" /></td>
			</tr>
			<tr>
				<td height="30" align="right">计量单位：</td>
				<td><input type="text" name="unit" id="unit" /></td>
			</tr>
				<tr>
				<td height="30" align="right">商品规格：</td>
				<td><table width="600" border="0" cellspacing="0"
						cellpadding="0">
						<tr>
							<td height="30" align="right" bgcolor="#EEE" colspan="4">
								<div>
									<input type="button" name="button" id="btn_addpro" value="添加商品规格" />
								</div>
							</td>
						</tr>
						<tr>
							<td align="center" bgcolor="#CCCCCC" colspan="4">
								<div id="probox">
									<div>
										SKU编码：<input name="prosku[]" type="text" id="prosku" size="15" /> 
										库存下限：<input name="prolower[]" type="text" id="prolower" size="8" /> 
										重量/G：<input name="proweight[]" type="text" id="proweight" size="8" />
										<input type="button" name="btn_delpro" id="btn_delpro" value="删除" />
									</div>
								</div>
						</tr>
					</table></td>
			</tr>
			<tr>
				<td height="30" align="right">&nbsp;</td>
				<td>
				<input type="submit" name="button" id="button" value="添加" />
				<input type="button" name="button3" id="button3" value="返回列表" onclick="window.location.href='<{:U('prolist')}>'" />
				</td>
			</tr>
			<tr>
				<td></td>
				<td height="30" colspan="2">
					<div style="font-family: 微软雅黑, Tahoma; letter-spacing: 2px; display: block;" id="result"></div>
				</td>
			</tr>
		</table>
	</form>

<script>
	// FROM  Submit 

	$('#form1').ajaxForm({
		beforeSubmit : checkForm, // pre-submit callback
		success : complete, // post-submit callback
		dataType : 'json'
	});
	function checkForm() {
		/*
		if( '' == $.trim($('#title').val())){
		    $('#result').html('标题不能为空').show();
		    return false;
		}
		 */
		//可以在此添加其它判断
	}
	function complete(data) {
		if (data.status == 1) {
			$('#result').html(data.info).show().fadeOut(2000);
		} else {
			$('#result').html(data.info).show();
		}
	}

	$(document).ready(function() {
		$("#btn_addpro").bind('click', function(){
			var n = $("#probox");
			var html = '<div>';
			html += ' SKU编码：<input name="prosku[]" type="text" id="prosku" size="15" /> ';
			html += ' 库存下限：<input name="prolower[]" type="text" id="prolower" size="8" /> ';
			html += ' 重量/G：<input name="proweight[]" type="text" id="proweight" size="8" /> ';
			html += ' <input type="button" name="button" id="btn_delpro" value="删除" />';
			html += '</div>';
			n.append(html);
		});
		
		
		$("#btn_delpro").live('click', function(){
			var t = $(this);
			t.parent("div").remove();
		} );
		
	});
</script>
</body>
</html>
